﻿<Window x:Class="Waf.BookLibrary.Library.Presentation.Views.ShellWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:waf="http://waf.codeplex.com/schemas"
    xmlns:p="clr-namespace:Waf.BookLibrary.Library.Presentation.Properties"
    xmlns:c="clr-namespace:Waf.BookLibrary.Library.Presentation.Converters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:dd="clr-namespace:Waf.BookLibrary.Library.Presentation.DesignData"
    mc:Ignorable="d" d:DataContext="{d:DesignInstance dd:SampleShellViewModel, IsDesignTimeCreatable=True}"
    Title="{Binding Title}" Icon="{StaticResource BookLibraryImageSource}"
    waf:ValidationHelper.IsEnabled="true" waf:ValidationHelper.IsValid="{Binding IsValid, Mode=OneWayToSource}"
    Height="600" Width="900">
    
    <Window.InputBindings>
        <KeyBinding Command="{Binding SaveCommand}" Key="S" Modifiers="Control"/>
        <KeyBinding Command="{Binding AboutCommand}" Key="F1"/>
    </Window.InputBindings>
    
    <DockPanel>
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="{x:Static p:Resources.DataMenu}">
                <MenuItem Command="{Binding SaveCommand}" Header="{x:Static p:Resources.SaveMenu}" Icon="{StaticResource SaveImage}" 
                          InputGestureText="{x:Static p:Resources.ControlS}"/>
                <Separator/>
                <MenuItem Command="{Binding ExitCommand}" Header="{x:Static p:Resources.ExitMenu}"/>
            </MenuItem>
            <MenuItem Header="{x:Static p:Resources.EditMenu}">
                <MenuItem Command="ApplicationCommands.Undo" Header="{x:Static p:Resources.UndoMenu}" Icon="{StaticResource UndoImage}"
                          InputGestureText="{x:Static p:Resources.ControlZ}"/>
                <MenuItem Command="ApplicationCommands.Redo" Header="{x:Static p:Resources.RedoMenu}" Icon="{StaticResource RedoImage}"
                          InputGestureText="{x:Static p:Resources.ControlY}"/>
                <Separator/>
                <MenuItem Command="ApplicationCommands.Cut" Header="{x:Static p:Resources.CutMenu}" Icon="{StaticResource CutImage}"
                          InputGestureText="{x:Static p:Resources.ControlX}"/>
                <MenuItem Command="ApplicationCommands.Copy" Header="{x:Static p:Resources.CopyMenu}" Icon="{StaticResource CopyImage}"
                          InputGestureText="{x:Static p:Resources.ControlC}"/>
                <MenuItem Command="ApplicationCommands.Paste" Header="{x:Static p:Resources.PasteMenu}" Icon="{StaticResource PasteImage}"
                          InputGestureText="{x:Static p:Resources.ControlV}"/>
                <MenuItem Command="EditingCommands.Delete" Header="{x:Static p:Resources.DeleteMenu}" Icon="{StaticResource DeleteImage}"
                          InputGestureText="{x:Static p:Resources.Del}"/>
                <Separator/>
                <MenuItem Command="ApplicationCommands.SelectAll" Header="{x:Static p:Resources.SelectAllMenu}"
                          InputGestureText="{x:Static p:Resources.ControlA}"/>
            </MenuItem>
            <MenuItem Header="{x:Static p:Resources.HelpMenu}">
                <MenuItem Command="{Binding AboutCommand}" Header="{x:Static p:Resources.AboutMenu}"
                          InputGestureText="{x:Static p:Resources.F1}"/>
            </MenuItem>
        </Menu>

        <ToolBarTray DockPanel.Dock="Top">
            <ToolBar>
                <Button Command="{Binding SaveCommand}" Content="{StaticResource SaveImage}" ToolTip="{x:Static p:Resources.Save}"/>
                <Separator/>
                <Button Command="ApplicationCommands.Undo" Content="{StaticResource UndoImage}" ToolTip="{x:Static p:Resources.Undo}"/>
                <Button Command="ApplicationCommands.Redo" Content="{StaticResource RedoImage}" ToolTip="{x:Static p:Resources.Redo}"/>
                <Button Command="ApplicationCommands.Cut" Content="{StaticResource CutImage}" ToolTip="{x:Static p:Resources.Cut}"/>
                <Button Command="ApplicationCommands.Copy" Content="{StaticResource CopyImage}" ToolTip="{x:Static p:Resources.Copy}"/>
                <Button Command="ApplicationCommands.Paste" Content="{StaticResource PasteImage}" ToolTip="{x:Static p:Resources.Paste}"/>
            </ToolBar>
        </ToolBarTray>

        <StatusBar DockPanel.Dock="Bottom">
            <StatusBarItem Content="{Binding DatabasePath}" ContentStringFormat="{x:Static p:Resources.DatabasePath}"/>
        </StatusBar>

        <TabControl Padding="0">
            <TabItem Header="{x:Static p:Resources.BookLibrary}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="300"
                                          MinWidth="{Binding Content.MinWidth, ElementName=bookViewPresenter}"/>
                    </Grid.ColumnDefinitions>

                    <ContentControl Content="{Binding ShellService.BookListView}" Grid.Row="0" Grid.Column="0" Margin="0,0,5,0"/>

                    <ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="0" Grid.Column="1">
                        <ContentControl x:Name="bookViewPresenter" Content="{Binding ShellService.BookView}" Focusable="False"/>
                    </ScrollViewer>

                    <GridSplitter HorizontalAlignment="Right" VerticalAlignment="Stretch" Width="4" Grid.Row="0" Grid.Column="0"/>
                </Grid>
            </TabItem>
            <TabItem Header="{x:Static p:Resources.AddressBook}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="300" 
                                          MinWidth="{Binding Content.MinWidth, ElementName=personViewPresenter}"/>
                    </Grid.ColumnDefinitions>

                    <ContentControl Content="{Binding ShellService.PersonListView}" Grid.Row="0" Grid.Column="0" Margin="0,0,5,0"/>

                    <ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="0" Grid.Column="1">
                        <ContentControl x:Name="personViewPresenter" Content="{Binding ShellService.PersonView}" Focusable="False"/>
                    </ScrollViewer>

                    <GridSplitter HorizontalAlignment="Right" VerticalAlignment="Stretch" Width="4" Grid.Row="0" Grid.Column="0"/>
                </Grid>
            </TabItem>
            <TabItem Header="{x:Static p:Resources.Reporting}" Visibility="{Binding ShellService.IsReportingEnabled, Converter={StaticResource BoolToVisibilityConverter}}">
                <ContentControl>
                    <ContentControl.Style>
                        <Style TargetType="ContentControl">
                            <Style.Triggers>
                                <Trigger Property="IsVisible" Value="True">
                                    <Setter Property="Content" Value="{Binding ShellService.LazyReportingView.Value}"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </ContentControl.Style>
                </ContentControl>
            </TabItem>
        </TabControl>

    </DockPanel>
    
</Window>
